package dk.au.cs.bdsi.sms.activities;

import dk.au.cs.bdsi.core.representation.Identifier;
import dk.au.cs.bdsi.core.representation.ServiceUri;
import dk.au.cs.bdsi.sms.domain.Sms;
import dk.au.cs.bdsi.sms.repositories.SmsRepository;
import dk.au.cs.bdsi.sms.representation.SmsRepresentation;

/**
 * Retrieves a {@link Sms} by its identification (as extracted from the supplied
 * {@link ServiceUri}) and returns a {@link SmsRepresentation} of it.
 */
public class ReadSmsActivity {
	public SmsRepresentation retrieve(ServiceUri smsUri) {
		Identifier id = smsUri.getId();
		Sms s = SmsRepository.current().get(id);
		if (s == null) throw new NoSuchSmsException();
		
		return SmsRepresentation.createResponseRepresentation(s, smsUri);
	}
}
